
package nothing.dao.hibernate;

import nothing.model.FoodNutrition;
import nothing.dao.FoodNutritionDao;
import org.appfuse.dao.hibernate.GenericDaoHibernate;

import java.util.List;

public class FoodNutritionDaoHibernate extends GenericDaoHibernate<FoodNutrition, Long> implements FoodNutritionDao {

    public FoodNutritionDaoHibernate() {
        super(FoodNutrition.class);
    }

    @SuppressWarnings("unchecked")
    public List<FoodNutrition> findByNutritionName(String name) {
        return getHibernateTemplate().find("from FoodNutrition fn, Nutrition n where fn.nutrition = n and n.name=?", name);
    }

    // @TODO Should this not take recipe step into account?
    @SuppressWarnings("unchecked")
    public List<FoodNutrition> findByFoodName(String name) {
        return getHibernateTemplate().find("from FoodNutrition fn, Food f where fn.food = f and f.name=?", name);
    }
}


